package studay;

import studay.adapter.cls.Adapter;
import studay.adapter.cls.TargetModule;
import studay.brideg.HWPhone;
import studay.brideg.RedColor;
import studay.brideg.SXPhone;
import studay.brideg.YellowColor;
import studay.builder.Computer;
import studay.builder.Director;
import studay.builder.HeightComputerBuilder;
import studay.builder.LowComputerBuilder;
import studay.chain.*;
import studay.command.*;
import studay.composite.File;
import studay.composite.Folder;
import studay.composite.Root;
import studay.decorator.BigBike;
import studay.decorator.Bike;
import studay.decorator.RSCBikeDecorator;
import studay.decorator.SuonaBikeDecorator;
import studay.factory.FactoryProducer;
import studay.factory.OrderFactory;
import studay.flyweight.CloudWebSite;
import studay.flyweight.Company;
import studay.flyweight.WebSiteFactory;
import studay.observe.AnnaObserver;
import studay.observe.BossConcreteSubject;
import studay.observe.LWObserver;
import studay.observe.Observer;
import studay.prototype.Person;
import studay.proxy.DigitalSell;
import studay.proxy.DigitalSellProxy;
import studay.proxy.DigitalSellReal;
import studay.strategy.DiscountActivity;
import studay.strategy.NormalActivity;
import studay.strategy.ProductOrder;
import studay.strategy.PromotionContext;
import studay.template.AbstractProjectManager;
import studay.template.PayServiceProjectManager;
import studay.template.UserServiceProjectManager;

/**
 * @program: 设计模式
 * @description: 入口
 * @author: Tom
 * @create: 2022-01-05 22:26
 **/
public class Main {
    public static void main(String[] args) throws CloneNotSupportedException {
//        OrderFactory wechatOrderFactory = FactoryProducer.getFactory("WECHAT");
//        wechatOrderFactory.createPay().unifiedorder();
//        wechatOrderFactory.createRefund().refund();

//        Person  person1 = new Person();
//        person1.setName("小明");
//        person1.setAge("18");
//        person1.getList().add("ccc");
//
////        Person person2 = person1.clone(); //浅拷贝
//        Person person2 = person1.deepClone(); //深拷贝
//
//        person2.setName("anna小姐姐");
//        person2.getList().add("bbb");
//
//        System.out.println("person1="+person1.getAge()+"person1="+person1.getName());
//        System.out.println("person2="+person2.getAge()+"person2="+person2.getName());

//        Director director = new Director();
//        Computer lowComputer = director.create(new LowComputerBuilder());
//        Computer heightComputer = director.create(new HeightComputerBuilder());
//
//        System.out.println(lowComputer.toString());
//        System.out.println(heightComputer.toString());

//        TargetModule targetModule = new Adapter();
//        targetModule.methodA();

//        HWPhone hwPhone = new HWPhone(new RedColor());
//        hwPhone.run();
//
//        SXPhone sx = new SXPhone(new YellowColor());
//        sx.run();

//        Root root1 = new Folder("C://");
//
//        Root deskTop = new Folder("桌面");
//
//        Root myComuter = new Folder("我的电脑");
//
//        Root javaFile = new File("HelloWord.java");
//
//        root1.addFile(deskTop);
//        root1.addFile(myComuter);
//        myComuter.addFile(javaFile);
//
//        root1.display(0);

        //选个自行车
//        Bike bike = new BigBike();
//
//        //搭配防爆胎
//        bike = new RSCBikeDecorator(bike);
//
//        //搭配喇叭
//        bike = new SuonaBikeDecorator(bike);
//        bike = new SuonaBikeDecorator(bike);
//
//        System.out.println(bike.getDescription()+",价格:"+ bike.getPrice());

//        DigitalSell realObj = new DigitalSellReal();
//        realObj.sell();
//
//        DigitalSell proxy = new DigitalSellProxy();
//        proxy.sell();
//        WebSiteFactory factory = new WebSiteFactory();
//        CloudWebSite companySite = factory.getWebSiteByKey("企业官网");
//        companySite.run(new Company("小弟科技"));
//
//        CloudWebSite companySite1 = factory.getWebSiteByKey("企业官网");
//        companySite1.run(new Company("需要课堂"));
//
//        CloudWebSite companySite2 = factory.getWebSiteByKey("后台管理端");
//        companySite2.run(new Company("字节跳动"));
//
//
//        System.out.println("网站分类总数"+factory.getWebsiteCategorySize());

//        ProductOrder productOrder = new ProductOrder(800,1,33);
//        PromotionContext context;
//        context = new PromotionContext(new NormalActivity());
//        double v = context.executeStrategy(productOrder);
//        System.out.println(v);
//
//        ProductOrder productOrder1 = new ProductOrder(800,1,33);
//        PromotionContext context1;
//        context1 = new PromotionContext(new DiscountActivity(0.8));
//        double v1 = context1.executeStrategy(productOrder1);
//        System.out.println(v1);

//        AbstractProjectManager abstractProjectManager;
//
//        abstractProjectManager = new PayServiceProjectManager();
//        abstractProjectManager.processProject();
//
//        System.out.println("==================");
//        abstractProjectManager = new UserServiceProjectManager();
//        abstractProjectManager.processProject();

//        BossConcreteSubject subject = new BossConcreteSubject();
//
//        Observer  lwobserve = new LWObserver();
//        Observer annaobserve= new AnnaObserver();
//
//        subject.addObserver(lwobserve);
//        subject.addObserver(annaobserve);
//
//        subject.doSomething();
//        RiskControlManager firstRiskCOntrol = new FirstRiskControlManager("初级风控");
//        RiskControlManager secondRiskCOntrol = new SecondRiskControlManager("中级风控");
//        RiskControlManager thirdRiskCOntrol = new ThiredRiskControlManager("高级风控");
//
//        firstRiskCOntrol.setSuperior(secondRiskCOntrol);
//        secondRiskCOntrol.setSuperior(thirdRiskCOntrol);
//
//        Request request1 = new Request();
//        request1.setRequestType(RequestType.TRANSFER.name());
//        request1.setMoney(1001);
//        firstRiskCOntrol.handlerRequest(request1);

        ConditionReceiver receiver = new ConditionReceiver();
        Command onCommand= new OnCommand(receiver);
        Command offCommand= new OffCommand(receiver);
        Command coolCommand= new CoolCommand(receiver);
        Command warmCommand= new WarmCommand(receiver);

        AppInvoker appInvoker = new AppInvoker();
        appInvoker.setOnCommand(onCommand);
        appInvoker.setOffCommand(offCommand);
        appInvoker.setCoolCommand(coolCommand);
        appInvoker.setWarmCommand(warmCommand);

        appInvoker.on();
        appInvoker.off();
        appInvoker.cool();
        appInvoker.warm();
    }
}
